﻿using DreamWork.Configuration;
using DreamWork.Net;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class EarthNetServiceCollectionExtensions
    {

        //public static IServiceCollection AddAPIClient(this IServiceCollection services, string name, Action<HttpClient> configureClient)
        //{
        //    if (services == null)
        //    {
        //        throw new ArgumentNullException(nameof(services));
        //    }

        //    if (name == null)
        //    {
        //        throw new ArgumentNullException(nameof(name));
        //    }

        //    services = services.AddTransient<IAuthenTicationOptions>((serviceProvider) =>
        //   {
        //       var options = new AuthenTicationOptions
        //       {
        //           Name = name,
        //           UseAuthentication = false
        //       };
        //       return options;
        //   });
        //    var builder = services.AddHttpClient()
        //            .AddHttpClient<IRestAPIClient,RestAPIClient>(name,client=>
        //            {
        //                client.DefaultRequestHeaders.Add("Accept", "application/json");
        //                configureClient(client);
        //            });

        //    return builder.Services;
        //}
        //public static IServiceCollection AddAPIClient(this IServiceCollection services, string name, Action<HttpClient> configureClient, Action<AuthenTicationOptions> configOptions)
        //{
        //    if (services == null)
        //    {
        //        throw new ArgumentNullException(nameof(services));
        //    }

        //    if (name == null)
        //    {
        //        throw new ArgumentNullException(nameof(name));
        //    }

        //    var builder2 = services.AddTransient<IAuthenTicationOptions>((serviceProvider) =>
        //    {
        //        var options = new AuthenTicationOptions
        //        {
        //            Name = name
        //        };
        //        configOptions(options);
        //        return options;
        //    });
        //    services.AddHttpClient()
        //        .AddHttpClient<IRestAPIClient>(client =>
        //        {
        //            client.DefaultRequestHeaders.Add("Accept", "application/json");
        //            configureClient(client);
        //        });

        //    return builder2;
        //}
    }
}
